package com.api.controller;

import com.api.model.dto.interfacceInfo.InterfaceInfoAddDTO;
import com.api.model.dto.interfacceInfo.InterfaceInfoQueryDTO;
import com.api.model.dto.interfacceInfo.InterfaceInfoUpdateDTO;
import com.api.model.dto.interfacceInfo.VerifyInterfaceInfoDTO;
import com.api.model.entity.InterfaceInfo;
import com.api.model.reslut.Result;
import com.api.model.reslut.ResultPage;
import com.api.model.vo.InterfaceInfoVo;
import com.api.service.InterfaceInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/info")
public class InterfaceInfoController {

    @Resource
    private InterfaceInfoService interfaceInfoService;

    /**
     * 查询
     * @return
     */
    @PostMapping("/get/page")
    public Result<ResultPage<InterfaceInfoVo>> getInterfaceInfoPage(@RequestBody InterfaceInfoQueryDTO interfaceInfoQueryDTO){
        ResultPage<InterfaceInfoVo> res =  interfaceInfoService.getInterfaceInfoPage(interfaceInfoQueryDTO);
        return Result.success(res);
    }

    /**
     * 查询根据id
     * @return
     */
    @GetMapping("/get/one")
    public Result<InterfaceInfoVo> getInterfaceById(Integer id){
        InterfaceInfoVo  res = interfaceInfoService.getInterfaceById(id);
        return Result.success(res);
    }

    /**
     * 添加
     * @return
     */
    @PostMapping("/add")
    public Result addInterfaceInfo(@RequestBody InterfaceInfoAddDTO interfaceInfoAddDTO){
        interfaceInfoService.addInterfaceInfo(interfaceInfoAddDTO);
        return Result.success();
    }

    /**
     * 更新
     * @return
     */
    @PostMapping("/update")
    public Result updateInterfaceInfo(@RequestBody InterfaceInfoUpdateDTO interfaceInfoUpdateDTO){
        interfaceInfoService.updateInterfaceInfo(interfaceInfoUpdateDTO);
        return Result.success();
    }


    /**
     * 删除
     * @return
     */
    @GetMapping("/delete")
    public Result deleteInterfaceInfo(Integer id){
        interfaceInfoService.deleteInterfaceInfo(id);
        return Result.success();
    }

    // 审核 未审核0 通过1 拒绝2
    @PostMapping("/verify")
    public Result verifyInterfaceInfo(@RequestBody VerifyInterfaceInfoDTO verifyInterfaceInfoDTO){
        interfaceInfoService.verifyInterfaceInfo(verifyInterfaceInfoDTO);
        return Result.success();
    }
}
